#d;
use "${analysis}/lsms_fao_merged.dta", replace;

for any l_dist_road l_dist_popcenter l_dist_market l_dist_borderpost l_dist_admctr \ num 1/5:
 global indvarY="X";

 
sort HHID;
local i 1;
while `i' <= 5 {;
	local append_replace="append";
	if `i'==1 {;
		local append_replace="replace";
		};
	
	xi: reg used_fert_app ${indvar`i'} i.country i.year, cluster(cluster);
	sum used_fert_app if e(sample);
	local depvar_mean=r(mean);
	local depvar_sd=r(sd);
	sum ${indvar`i'} if e(sample);
	local indvar_mean=r(mean);
	local indvar_sd=r(sd);
	quietly gen x=e(sample);
	quietly sort x HHID;
	quietly count if x==1 & HHID!=HHID[_n-1];
	local individuals=r(N);
	quietly drop x;
	outreg2 ${indvar`i'} using "${pool_results}/LSMS-ISA_usage.out", 
	 nonote se symb(***,**,*) `append_replace' bdec(3) addstat("depvar mean", `depvar_mean', "depvar sd", `depvar_sd', 
	 "indvar mean", `indvar_mean', "indvar sd", `indvar_sd', "# of village", e(N_clust), "# individuals", `individuals') nocons;
	local i = `i' + 1;
	};
